﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _MetalSlug.Form.PlayGame;
using _MetalSlug.Mementoes;

namespace _MetalSlug.Form.ScreenSystem.Message
{
    public class LoadingMessage: MyMessage
    {
        String NameOfPlayer;
        int CurrentMap;
        int GameCore;
        
        public LoadingMessage(object Content)
        {
            TypeOfMessage = TYPE.LOADING;
            if (!String.IsNullOrEmpty(Content.ToString()))
            {
                String[] parameters = Content.ToString().Split(' ');
                NameOfPlayer = parameters[0];
                CurrentMap = int.Parse(parameters[1]);
                GameCore = int.Parse(parameters[2]);
            }      
        }

        public override void Process(MyScreen SendWindow, MyScreen ReceiveWindow)
        {
            if(ReceiveWindow.TypeOfWindow == MyScreen.TYPE.PLAYGAME)
            {
                PlayGameScreen MyPlayGameScreen = (PlayGameScreen)ReceiveWindow;
                MyPlayGameScreen.SetMissionBuilder(NameOfPlayer,GameCore, CurrentMap);
                Boolean isComplete = MyPlayGameScreen.LoadingMission();
                if (isComplete)
                {
                    SendWindow.Send(ReceiveWindow.TypeOfWindow, TYPE.SHOW, null);
                }
                
            }
        }
    }
}
